#pragma once

#include "Resource.h"

namespace RenderSystem
{
	class VertexBuffer;
	class IndexBuffer;
	class VertexDeclaration;

	class Material;
	class MeshManager;

	class SubMesh
	{
	public: 
		SubMesh( void );
		~SubMesh( void );

		void SetDeclaration( VertexDeclaration* pDecl );

		void SetMaterial( Material* pMaterial );
		Material* GetMaterial( void ) const;

	protected:

		VertexDeclaration*		m_pDecl;

		VertexBuffer*			m_pVB;
		IndexBuffer*			m_pIB;

		Material*				m_pMaterial;
	};

	class Mesh
		:public Resource
	{
	public:

		typedef std::vector< SubMesh* >		SubMeshes;
		typedef SubMeshes::iterator			SubMeshesIterator;
		typedef SubMeshes::const_iterator	SubMeshesConstIterator;

		Mesh( const String& strId, MeshManager& rMeshMgr );
		virtual ~Mesh(void);

		//Resource Interface implement
		virtual bool Load( const String& strPath );
		virtual bool Unload( void );

		uint32 GetSubMeshCount( void );
		SubMesh* GetSubMesh( uint32 uIdx ) const;

	protected:

		//Resource Interface implement
		virtual Instance* _CreateInstanceImpl( const String& strInstanceId );

	protected:

		SubMeshes		m_subMeshes;
	};
}